package com.atguigu.juc.t1;


import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class T3 {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
//        FutureTask<Long> task1 = new FutureTask<>(new Callable<Long>() {
//            @Override
//            public Long call() throws Exception {
//                System.out.println("callable线程操作");
//                return 100L;
//            }
//        });
//
//        new Thread(task1).start();
//
//        Long aLong = task1.get();// 获得线程操作结果
//
//        System.out.println(aLong);
//    }

        FutureTask<Long> longFutureTask = new FutureTask<>(new Callable<Long>() {

            @Override
            public Long call() throws Exception {
                System.out.println("callable线程操作");
                return 500L;
            }
        });
        new Thread(longFutureTask).start();
        Long l = longFutureTask.get();
        System.out.println(l);
    }
}